<template>
	<div class="u-page" style="background:#f7f7f7">
		<section class="aui-flexView">
			<section class="aui-scrollView">

					<div class="aui-choice-white u-pt-15 u-pb-15">
						<div style="width: 93%;margin: 0 auto;">
							<div style="display: flex;justify-content: space-between;align-items: center;" v-if="JSON.stringify(addressObj) !== '{}'" @click="toSelectAddress">
								<div class="cont-right">
									<div class="u-flex u-fz-13">
										<span v-if="addressObj.DefaultStatus == 1">
											<div class="default-tag">默认</div>
										</span>
										<span class='address1'>{{addressObj.Region.replace(/'-'/g, '')}}-{{addressObj.StreetVillage.replace(/'-'/g, '')}}</span>
									</div>
									<div class="u-title u-fz-20 u-pt-5" v-if="addressObj.Address">{{addressObj.Address}}</div>
									<div class="u-pt-5 u-fz-15">
										<span>{{addressObj.Name}}</span>
										<span class="u-pl-5">{{addressObj.PhoneNum}}</span>
									</div>
								</div>
								<div>
									<u-icon name="arrow-right" color="#d6d2d2" size="28"></u-icon>
								</div>
							</div>
							<div v-else>
								<div class="aui-choice-white" style="display: flex;justify-content: space-between;" @click="toSelectAddress">
									<div class="u-title u-fz-20">请选择收货地址</div>
									<div class="u-flex u-col-center">
										<div class="u-center">
											<u-icon name="arrow-right" color="#d6d2d2" size="28"></u-icon>
										</div>
									</div>
								</div>
							</div>
						</div>
					</div>

					<div class="aui-choice-white border-radius-30">
						<div class="aui-flex aui-flex-default u-mt-10" @click="toGoodsDetails">
							<div class="aui-flex-goods">
								<img :src="solitaire.goodsImages.split(',')[0]" alt="">
							</div>
							<div class="aui-flex-box">
								<div class="solitaire-title">
									{{solitaire.title}}
								</div>
								<div class="u-fz-13" style="color: #9f9d9e;">{{solitaire.specification}}</div>
								<div class="aui-flex aui-flex-clear u-pt-5" style="display: flex;justify-content: space-between;">
									<div class="u-fz-19 u-font-bold" style="color: #ea4d5e;">&yen;{{solitaire.unitPrice}}</div>
									<u-number-box :disabled-input="true" :min="1" :max="buyQuantityMax" @change="calculate" v-model="solitaire.buyQuantity" v-if="buyQuantityMax"></u-number-box>
									<u-number-box :disabled-input="true" :min="1" @change="calculate" v-model="solitaire.buyQuantity" v-else></u-number-box>
								</div>
							</div>
						</div>
						<div class="aui-flex2">
						  <div class="aui-flex-box">优惠券</div>
						  <u-input style="color: red" type="select" v-model="coupon" input-align="right" placeholder="请选择" @click="selectCoupons" />
						</div>
						
						<div class="aui-flex2">
						  <div class="aui-flex-box">是否使用钱包余额抵扣</div>
							<div class="aui-flex-triangle" @click="useDeduction_show = true">{{useDeduction_text}}</div>
							<u-picker v-model="useDeduction_show" mode="selector" :default-selector="[0]" :range="useDeductionRange" range-key="lable"
								@confirm="selectDeduction"></u-picker>
						</div>
						
						<!-- 使用钱包余额抵扣 -->
						<div v-if="useDeduction == '1'">
							<div class="aui-flex2">
								<div class="aui-flex-box">抵扣金额</div>
								<div class="tpink-btn-color">-&yen;{{deductionAmount}}</div>
							</div>
							
							<div class="aui-flex2">
								<div class="aui-flex-box">钱包剩余金额</div>
								<div>&yen;{{remainAmount}}</div>
							</div>
						</div>
						
						<div class="aui-flex2">
							<div class="aui-flex-box">配送</div>
							<div>快递包邮</div>
						</div>
						<div class="aui-flex2">
							<div class="aui-flex-box">备注</div>
							<u-input v-model="orderRemarks" input-align="right" :placeholder-style="(remarkSwitch&&solitaire.remarkReminder)?'color:red;':''" :placeholder="solitaire.reminderContent?solitaire.reminderContent:'如有其他要求,请填写备注'"></u-input>
						</div>
					</div>

					<div class="aui-choice-white border-radius-30">
						<div style="width: 93%;margin: 0 auto;padding-bottom: 40rpx;">
							<div style="margin: 20rpx 0rpx;padding-top: 30rpx;font-weight: bolder;font-size: 30rpx;">
								附近区域服务商（售后服务点）
							</div>
							<div v-if="supplierList && supplierList.length > 0">
								<u-radio-group @change="radioGroupChange" v-model="selectedSupplierId" active-color="#eb5468">
									<u-radio v-for="(item, index) in supplierList" :key="index" :name="item.id">
										<div class="u-flex u-row-between u-col-center u-mb-5 u-pt-10 u-pl-10">
											<u-avatar :src="item.images" size="100" mode="square"></u-avatar>
											<div class="u-col-center u-flex-1 u-pl-10">
												<div class="u-title">
													{{item.storeName?item.storeName:''}}
												</div>
												<div class="commodity-no u-fz-13">{{item.address}}</div>
											</div>
										</div>
									</u-radio>
								</u-radio-group>
							</div>
						</div>
					</div>
					
			</section>

			<div style="height: 250rpx;"></div>

			<div class="aui-bar-footer">
				<div class="u-pb-5">
					<div class="notice-bar" @click="followOfficialAccount" v-if="!isCreator">
						点击<span style="text-decoration: underline;">关注公众号</span>，下单后完成品牌分享任务，立即返现¥{{solitaire.consumerShareReward?solitaire.consumerShareReward:0}}
					</div>
					<div class="notice-bar" @click="followOfficialAccount" v-else>
						<span style="text-decoration: underline;">关注公众号</span>，下单品牌返¥{{foremanReward?foremanReward:0}}，完成分享任务再返¥{{solitaire.consumerShareReward?solitaire.consumerShareReward:0}}！
					</div>
				</div>
				<div class="aui-flex">
					<div class="aui-flex-box">
						应付金额：<span>&yen;{{temp_PayAmount}}</span>
					</div>
					<div>
						<u-button :disabled="isClick"
							:custom-style="{background:'#eb5468',padding:'52rpx 50rpx',color:'#fff',fontSize:'28rpx',borderRadius:'0rpx'}"
							hover-class="none" @click="placeOrder">提交订单</u-button>
					</div>
				</div>
			</div>

		</section>

		<!-- 选择上传的方式 -->
		<u-popup v-model="showItem" mode="bottom" @close="closePopup">
			<div class="popup-box">
				<div class="popup-item" v-for="(item, index) in chooseTypes" @click="clickPopup(item)">
					<div>{{item.text}}</div>
				</div>
			</div>
		</u-popup>

		<!-- 是否确定购买弹窗 -->
		<u-modal v-model="buy_show" confirm-text="确认" show-cancel-button :content="buy_show_text" @confirm="confirmBuy">
		</u-modal>

		<!-- 购买成功后的弹窗 -->
		<!-- <u-modal v-model="success_show" :show-confirm-button="false" :show-title="false" border-radius="0" width="70%">
			<div style="background-color: rgb(99,99,99);">
				<div class="success-modal-content">
					<div class="u-pt-60 u-fz-20 u-text-center font-weight-550 color-red">
						立即返现<span class="u-fz-30 u-pl-5">&yen;{{totalShareReward?totalShareReward:'0'}}</span>
					</div>
					<div class="success-modal-share">
						<button class="buy-goods-share" @click="createPoster(shareData.docUnid,shareData.shareAddress,shareData.route,shareData.style,shareData.taskTimes,shareData.posterData)"></button>
					</div>
				</div>
				<div class="u-mt-5 success-modal-bottom" @click="followOfficialAccount"></div>
				<div class="u-mt-15" style="display: flex;justify-content: center;" @click="closeSuccessModal">
					<u-icon name="close-circle" color="rgb(68,68,68)" size="45"></u-icon>
				</div>
			</div>
		</u-modal> -->
		<u-mask :show="success_show" :mask-click-able="false" z-index="9999">
			<div class="mask-solt">
				<div>
					<div class="success-modal-content">
						<div class="u-pt-60 u-text-center">
							<div class="u-fz-35 u-font-bold color-red line-height85">
								<span>&yen;</span>
								<span class="u-fz-60">{{totalShareRewardPrefix}}</span>
								<span>.{{totalShareRewardSuffix}}</span>
							</div>
						</div>
						<div class="success-modal-share">
							<button class="buy-goods-share" @click="createPoster(shareData.docUnid,shareData.shareAddress,shareData.route,shareData.style,shareData.taskTimes,shareData.posterData)"></button>
						</div>
					</div>
					<div class="u-mt-15 mask-close" @click="closeSuccessModal">
						<u-icon name="close-circle" color="rgb(68,68,68)" size="45"></u-icon>
						<!-- <u-image width="52rpx" height="52rpx"
							src="https://www-1308272144.cos.ap-guangzhou.myqcloud.com/Meily/icon/Common/close.png"></u-image> -->
					</div>
				</div>
			</div>
		</u-mask>

		<!-- 关注公众号弹窗 -->
		<u-mask :show="official_account_show" :mask-click-able="false" z-index="9999" mask-click-able="true" @click="closeOfficialAccount">
			<div class="mask-solt">
				<div>
					<div class="official-account-bg"></div>
				</div>
			</div>
		</u-mask>

		<!-- 弹窗生成海报 -->
		<u-modal v-model="poster_modal_show"
			confirm-text="完成3名好友扫码即可返现"
			confirm-color="#e55e97"
			:mask-close-able="true"
			:show-title="false"
			@confirm="SaveAlbum(PosterURL)">
			<u-image :src="PosterURL" mode="widthFix" @longpress="saveImg(PosterURL)"></u-image>
		</u-modal>

		<!-- 选择优惠券 -->
		<Coupon :show.sync="coupons_show"
		        ref="couponRef"
		        :goods-id="solitaire.goodsId"
		        :use-scope="solitaire.goodsId"
				:init="true"
		        @selected-event="couponList">
		</Coupon>

	</div>
</template>

<script>
	import globalData from "@/globalData";
	import Coupon from "./common/Coupon"
	export default {
		components: {
			Coupon
		},
		data() {
			return {
				solitaire: {}, // 接龙信息
				joinRecord: {},// 购买成功后返回的参与拼团记录对象
				temp_UnitPrice: '', // 用于记录未满折扣的单价
				temp_PayAmount: 0.00, // 用于记录应付金额
				showItem: false,
				isClick: false,
				buy_show: false,
				buy_show_text: '',
				success_show: false,
				privilegedStatus: '', // 用户是否享有支付特权。yes:是；no:否。默认：no
				orderRemarks: '',// 订单备注
				addressObj: {}, // 收货地址
				supplierList: [], // 匹配到的供应商列表
				selectedSupplier: {}, // 选中的供应商
				selectedSupplierId: '', // 选中的供应商记录唯一id
				chooseTypes: [{
						text: '全额付款',
						action: 'fullPayment'
					},
					{
						text: '支付0.01元',
						action: 'payALittle'
					},
					{
						text: '取消',
						action: 'closePopup'
					}
				],
				shareData: {
					docUnid: '',
					shareAddress: '',
					route: '',
					style: 9,
					shareBtnStyle: 'buy-goods-share',
					type: 2,
					taskTimes: 3,
					posterData: {
						imageURL: '', // 商品主图URL地址
						productName: '', // 商品名称
						productPrice: '', // 商品价格
						invitemsg: '邀请您参与平台活动', // 邀请内容。可不传，默认邀请
						type: '',
						giudeText: '长按识别小程序 参与活动',
						priceDesc: '玫丽专享价'
					},
				},
				official_account_show: false,//关注公众号弹窗
				poster_modal_show: false,//弹窗生成海报
				PosterURL: '',//海报地址
				totalShareReward: '',// 消费者总分享报酬
				remark: '',//备注
				remarkSwitch: false,
				totalShareRewardPrefix: 0,//分享弹窗显示金额前半部分
				totalShareRewardSuffix: 0,//分享弹窗显示金额后半部分
				buyType: 0,// 购买方式。0:拼团购买；1:直接购买。默认0
				entity: 'YES',// 是否为实物。YES:是；NO:不是
				isCreator: false,//是否为发起人
				foremanReward: 0,//销售佣金
				buyQuantityMax: '',// 可购买的最大数量
				coupons_show: false,//优惠券组件显示控制
				coupon: '',//优惠券显示
				selectedCouponObj: {},//选中的优惠券对象
				goodsType: '',
				officialAccountUrl: 'https://mp.weixin.qq.com/s/IYKtVOzoorlNeIXBB4yhjQ',
				useDeduction_show: false,
				useDeduction_text: '是',// 是否使用钱包余额抵扣
				useDeduction: '1',
				useDeductionRange: [
					{
						id: '1',
						lable: '是'
					},
					{
						id: '0',
						lable: '否'
					}
				],
				walletTotalAmount: 0.00,// 钱包总金额
				deductionAmount: 0.00,// 抵扣金额
				remainAmount: 0.00,// 抵扣后的剩余金额
				amountBeforeDeduction: 0.00,// 记录抵扣前的实付金额
			}
		},

		onLoad(options) {

			// 未登录跳转到登录页面
			var loginRes = this.checkLogin()
			if (!loginRes) {
				return false;
			}

			if(this.isNotNull(options.buyType)){
				this.buyType = options.buyType;
			}

			let solitaire_info = decodeURIComponent(options.solitaire)
			if (this.isNotNull(solitaire_info)) {
				this.solitaire = JSON.parse(solitaire_info)
				this.solitaire.buyQuantity = 1; // 初始化购买数量为1
				this.solitaire.payAmount = this.solitaire.unitPrice; // 初始化应付价格为单价
				this.temp_UnitPrice = this.solitaire.unitPrice;
				this.temp_PayAmount = this.solitaire.unitPrice;

				// 初始化参与者信息
				const userInfo = uni.getStorageSync('userInfo')
				this.solitaire.partnerId = userInfo.userId; // 参与者id
				this.solitaire.partnerName = userInfo.nickName; // 参与者昵称
				this.solitaire.partnerAvatarUrl = userInfo.avatarUrl; // 参与者头像
				//判断是否为发起人
				if(this.solitaire.initiatorId == userInfo.userId){
					this.isCreator = true
				}

				// 获取销售佣金
				this.getGoodsDetails(this.solitaire.goodsId, this.solitaire.goodsNo, this.solitaire.cycle);
			}

			// 根据userid获取支付特权状态
			this.getPrivilegedStatus();
			
			// 获取用户钱包金额
			this.getWalletAmount();

			// 计算需要支付的金额
			// this.calculate();

			// 选中的收货地址
			uni.$on("AddressObj", (obj = {}) => {
				this.addressObj = obj;

				// 获取供货商
				this.getSupplierList(this.addressObj);
			});

			// 获取默认收货地址
			if (JSON.stringify(this.addressObj) === '{}') {
				this.getDefaultAddress();
			} else {
				// 获取供货商
				this.getSupplierList(this.addressObj);
			}

			// 分享组件数据初始化
			// 直接购买：分享商品销售详情
			this.shareData.docUnid = this.solitaire.id;
			this.shareData.shareAddress = '/pages_private_scene2/GroupPurchase/DistributionGoods?goodsNo=' + this.solitaire.goodsNo + '&goodsId=' + this.solitaire.goodsId;
			this.shareData.route = this.getCurrentPageUrl(this);
			this.shareData.imageUrl = this.solitaire.goodsImages.split(",")[0];
			this.shareData.shareTitle = '每件赚¥' + parseFloat(this.solitaire.foremanReward ? this.solitaire
					.foremanReward : 0) + '~¥' + (parseFloat(this.solitaire.foremanReward ? this.solitaire
					.foremanReward : 0) + parseFloat(this.solitaire.tenThousandOnlineCashback ? this.solitaire
					.tenThousandOnlineCashback : 0) + parseFloat(this.solitaire.tenThousandProviderCashback ?
					this.solitaire.tenThousandProviderCashback : 0)).toFixed(2) +
				'！！代理销售' + this.solitaire.goodsName;

			this.shareData.posterData.imageURL = this.solitaire.goodsImages.split(',')[0];
			this.shareData.posterData.productName = this.solitaire.goodsName;
			this.shareData.posterData.productPrice = this.solitaire.discountPrice;
		},

		methods: {

			/**
			 * 判断用户是否享有支付特权
			 */
			async getPrivilegedStatus() {
				const userInfo = uni.getStorageSync('userInfo')
				let result = await this.$u.api.unifyMiniRestGet({
					systemid: "meily",
					url: "/user/canQuickPay/" + userInfo.userId,
					loading: false // 默认发起请求会有一个全局的Loading，设置false可去掉
				});
				if (result.code == 200) {
					this.privilegedStatus = result.data
				}
			},


			/**
			 * 计算需要支付的金额
			 */
			calculate() {
				console.log("开始计算需要支付的金额.......")
				if (this.isNotNull(this.solitaire.unitPrice) && this.isNotNull(this.solitaire.buyQuantity)) {
					this.temp_PayAmount = (parseFloat(this.solitaire.unitPrice) * Number(this.solitaire.buyQuantity)).toFixed(2);
					if(this.isNotNull(this.selectedCouponObj.couponAmount)){
						this.temp_PayAmount = (parseFloat(this.temp_PayAmount) - parseFloat(this.selectedCouponObj.couponAmount)).toFixed(2);
					}
					
					// 使用抵扣前，需要记录抵扣前的实付金额，否则若再次选择不使用抵扣时，无法重新计算不使用抵扣的金额
					this.amountBeforeDeduction = this.temp_PayAmount;
				}
				// 计算抵扣金额
				this.calculateDeductionAmount();
			},
			
			/**
			 * 获取用户钱包金额
			 */
			async getWalletAmount(){
				const userInfo = uni.getStorageSync('userInfo')
				let res = await this.$u.api.unifyMiniRest({
					systemid: "payment",
					url: "/points/token",
					userId: userInfo.userId,
					loading: false
				});
				if(res.code == 200 && this.isNotNull(res.data)){
					let token = res.data
					let tmpToken = this.sault_md5_token(token)
					let result = await this.$u.api.unifyMiniRest({
						systemid: "payment",
						url: "/wallet/getCoins",
						userId: userInfo.userId,
						token: token,
						authStr: tmpToken,
						loading: false
					});
					if(result.code == 200 && result.data){
						this.walletTotalAmount = result.data;// 钱包总余额
						this.remainAmount = this.walletTotalAmount;
						console.log("获取钱包余额成功！......");
						
						// 计算需要支付的金额
						this.calculate();
					}
				} else {
					this.showMSG('none','获取token出错啦')
				}
			},
			
			/**
			 * 弹出优惠卷
			 */
			selectCoupons() {
			  this.coupons_show = true
			},
			
			/**
			 * 选择优惠券
			 * @param {Object} list
			 * @param {Object} offerAmount
			 */
			couponList (list,offerAmount){
				this.selectedCouponObj = list[0]?list[0]:{}
				if (offerAmount === 0){
					this.coupon = '请选择'
				}
				this.coupon = '-￥' + offerAmount
				// 更改订单金额
				if (!isNaN(this.temp_PayAmount)){
					let total_price = this.temp_UnitPrice
					if (this.isNotNull(this.solitaire.buyQuantity)) {
						total_price = (parseFloat(this.temp_UnitPrice) * Number(this.solitaire.buyQuantity)).toFixed(2);
					}
					if(parseFloat(total_price) > parseFloat(offerAmount)){
						this.temp_PayAmount = (parseFloat(total_price).toFixed(2) - parseFloat(offerAmount).toFixed(2)).toFixed(2);
					}else{
						this.temp_PayAmount = 0.00
					}
					
					// 使用抵扣前，需要记录抵扣前的实付金额，否则若再次选择不使用抵扣时，无法重新计算不使用抵扣的金额
					this.amountBeforeDeduction = this.temp_PayAmount;
					
					// 计算抵扣金额
					this.calculateDeductionAmount();
				}
			},

			/**
			 * 是否使用钱包余额抵扣
			 * @param {Object} e
			 */
			selectDeduction($event) {
				let obj = this.useDeductionRange[$event]
				this.useDeduction = obj.id;
				this.useDeduction_text = obj.lable;
				
				// 计算抵扣金额
				this.calculateDeductionAmount();
			},
			
			/**
			 * 计算抵扣金额
			 */
			calculateDeductionAmount(){
				// 1.使用抵扣
				if(this.useDeduction == '1'){
					console.log("********使用抵扣*****")
					
					// 更改实付金额
					if (this.isNotNull(this.temp_PayAmount)){
						// 情况1：部分抵扣：钱包金额 > 实付金额
						if(parseFloat(this.walletTotalAmount) > parseFloat(this.temp_PayAmount)){
							this.remainAmount = (parseFloat(this.walletTotalAmount).toFixed(2) - parseFloat(this.temp_PayAmount).toFixed(2)).toFixed(2);
							this.deductionAmount = this.temp_PayAmount;
							this.temp_PayAmount = 0.00
						} else {
							// 情况2：全部抵扣：实付金额 >= 钱包金额
							this.remainAmount = 0.00;
							this.deductionAmount = this.walletTotalAmount;
							this.temp_PayAmount = (parseFloat(this.temp_PayAmount).toFixed(2) - parseFloat(this.walletTotalAmount).toFixed(2)).toFixed(2);
						}
					}
					console.log("********抵扣后*****")
					console.log("this.walletTotalAmount=", this.walletTotalAmount)
					console.log("this.remainAmount=", this.remainAmount)
					console.log("this.deductionAmount=", this.deductionAmount)
					
				} else if(this.useDeduction == '0'){
					console.log("********不使用抵扣*****")
					// 2.不使用抵扣
					if(this.isNotNull(this.amountBeforeDeduction)){
						this.temp_PayAmount = this.amountBeforeDeduction;
						this.deductionAmount = 0.00;
					}
				}
			},
			
			/**
			 * 获取默认收货地址（BPM）
			 */
			async getDefaultAddress() {
				const userInfo = uni.getStorageSync('userInfo')
				let result = await this.$u.api.unifyMiniRest({
					systemid: "meily",
					url: "/minrest",
					appid: 'meily',
					wf_num: 'R_meily_BL014',
					userId: userInfo.userId,
					nickName: userInfo.nickName,
					loading: false // 默认发起请求会有一个全局的Loading，设置false可去掉
				});
				if (result.code == '200') {
					if (result.data) {
						this.addressObj = result.data;

						// 获取供货商
						this.getSupplierList(this.addressObj);
					}
				}
			},

			/**
			 * 获取供货商
			 */
			async getSupplierList(addressObj) {

				let address = "";
				if (this.isNotNull(addressObj.Region) && this.isNotNull(addressObj.StreetVillage)) {
					address = addressObj.Region + "-" + addressObj.StreetVillage;
				}
				const userInfo = uni.getStorageSync('userInfo')
				let result = await this.$u.api.unifyMiniRest({
					systemid: "meily",
					url: "/provider/match",
					address: address,
					userId: userInfo.userId,
					loading: false // 默认发起请求会有一个全局的Loading，设置false可去掉
				});

				if (result.code == '200') {
					if (result.rows) {
						this.supplierList = result.rows;
						if (this.supplierList.length > 0) {
							this.selectedSupplierId = this.supplierList[0].id;
							this.selectedSupplier = this.supplierList[0];
						}

						// 2022-04-06 add 区域服务商隐藏掉“xxx居委会”（即隐藏第五级地址）
						this.supplierList.forEach((item, index) => {
							if(this.isNotNull(item.address) && item.address.indexOf("-") != -1){
								let arr = item.address.split('-');
								let length = arr.length;
								let new_address = "";
								if(length > 3){
									for(let i=0; i<length-1;i++){
										if(this.isNotNull(new_address)){
											new_address = new_address + "-" + arr[i];
										} else {
											new_address = arr[i];
										}
									}
								}
								/* // 第一个参数是要修改的数据, 第二个值是修改当前数组的哪一个字段,第三个是要修改为什么值
								this.$set(this.supplierList_show[index], `address`, new_address); */
								item.address = new_address;
							}

							if(this.isNotNull(item.storeName) && item.storeName.indexOf("-") != -1){
								let arr = item.storeName.split('-');
								let length = arr.length;
								let new_storeName = "";
								if(length > 3){
									for(let i=0; i<length-1;i++){
										if(this.isNotNull(new_storeName)){
											new_storeName = new_storeName + "-" + arr[i];
										} else {
											new_storeName = arr[i];
										}
									}
								}
								/* // 第一个参数是要修改的数据, 第二个值是修改当前数组的哪一个字段,第三个是要修改为什么值
								this.$set(this.supplierList_show[index], `storeName`, new_storeName); */
								item.storeName = new_storeName;
							}
						});
					}
				}
			},

			/**
			 * 提交订单
			 */
			async placeOrder() {
				// 第1步 判断是否已经选择了收货地址
				if (JSON.stringify(this.addressObj) === '{}') {
					this.$u.toast("请选择收货地址！");
					return
				} else if(!this.isNotNull(this.addressObj.Name)){
					this.$u.toast("收货人姓名不能为空！");
					return;
				} else if(!this.verificationName(this.addressObj.Name)){
					this.$u.toast("收货人姓名至少包含一个字母或一个中文！");
					return;
				} else if(!this.isNotNull(this.addressObj.PhoneNum)){
					this.$u.toast("手机号码不能为空！");
					return;
				} else if(!this.verificationPhone(this.addressObj.PhoneNum)){
					this.$u.toast("手机号码不合法！");
					return;
				} else if(!this.isNotNull(this.addressObj.Region) || !this.isNotNull(this.addressObj.StreetVillage) || !this.isNotNull(this.addressObj.Address)){
					// 检验地址是否填写完毕
					this.$u.toast("地址信息尚未完整！");
					return;
				} else if (JSON.stringify(this.selectedSupplier) === '{}') {
					// 第2步 判断是否已经选择了供应商
					this.$u.toast("请选择供应商！");
					return
				} else if (this.solitaire.remarkReminder==1 && !this.isNotNull(this.orderRemarks)) {
					this.remarkSwitch = true
					this.$u.toast("请填写备注！")
					return
				} else {
					this.buy_show_text = "一共" + this.solitaire.buyQuantity + "件商品，需要支付" + this.temp_PayAmount +
						"元，您确认购买吗？";
					this.buy_show = true;
				}
			},

			/**
			 * 确定购买(参与拼团)
			 * 1. 先判断当前用户是否受参与限制
			 * 2. 先支付
			 * 3. 后保存接龙记录
			 */
			async confirmBuy() {
				// 第1步 先判断当前用户是否受参与限制
				const userInfo = uni.getStorageSync('userInfo')
				let result = await this.$u.api.unifyMiniRest({
					systemid: "meily",
					url: "/buying/canJoin",
					mainDocunid: this.solitaire.id, // 拼团主文档ID
					partnerId: this.solitaire.partnerId, // 参与者id
					sceneAssetsId:this.solitaire.SceneAssetsId, // 定制ID
					sceneId: this.solitaire.SceneID, // 场景ID
					goodsId: this.solitaire.goodsId,// 商品id
					loading: true // 默认发起请求会有一个全局的Loading，设置false可去掉
				});
				if (result.code == "200") {
					// 第2步 支付。判断用户是否享有支付特权
					if (this.privilegedStatus == "yes") {
						// 是，则可以选择支付额度
						this.showItem = true;
					} else {
						// 否，全额付款
						this.doWxPay('fullPayment');
					}
				} else if (result.code == "201") {
					this.$u.toast(result.msg)
				} else {
					this.showMSG('error', '出错啦！')
				}
			},

			/**
			 * 支付
			 */
			async doWxPay(action) {

				// 支付订单ID
				this.solitaire.orderId = this.guid();// 商户订单号。可自定义也可让系统自动生成

				this.solitaire.payAmount = this.temp_PayAmount;

				// 显示 loading 提示框
				uni.showLoading({
					mask: true,
				});

				// 设置按钮为不可点击
				this.isClick = true;

				// 0.初始化订单信息
				// 格式化名字（名字超长处理）--- 暂不处理
				let Subject = this.formatSubject(this.solitaire.title, 25);

				let name = Subject + "-支付拼团费用";
				let price = 0;

				if (action == 'fullPayment') {
					console.log("********全额付款***********");
					price = (parseFloat(this.solitaire.payAmount) * 100).toFixed(0); // 全额付款
				}
				if (action == 'payALittle') {
					console.log("********支付0.01元***********");
					price = 1; // 支付一分钱
					this.entity = "NO";
				}

				// 定义商品信息串，建议这些字段定义规范并且固定（例如商品件数等数据），好方便订单系统进行展示
				let goodsInfo = {};
				goodsInfo.goodsNum = this.solitaire.buyQuantity + '件'; // 件数
				goodsInfo.goodsWeight = '0kg'; // 重量

				// 定义商家信息串，建议这些字段定义规范并且固定（例如下面这两个字段），好方便订单系统进行展示
				let mchInfo = {};
				mchInfo.mchname = ""; // 商家名称
				mchInfo.mchimage = ""; // 商家图标

				let obj = {};
				obj.userid = uni.getStorageSync('userInfo').userId;
				obj.openid = uni.getStorageSync('userInfo').openid;
				obj.tradeDesc = name;
				obj.payPrice = price; // 付款金额
				obj.productID = this.solitaire.goodsNo; // 商品编号
				obj.productUrl = ''; // 订单详情页地址
				obj.imageUrl = this.solitaire.goodsImages.split(',')[0]; // 商品图片
				obj.goodsInfo = goodsInfo;
				obj.mchInfo = mchInfo;
				obj.remark = name;
				obj.tradeNo = this.solitaire.orderId;
				// 业务数据
				let businessData = {
					address: JSON.stringify(this.addressObj),
					buyQuantity: this.solitaire.buyQuantity,
					cycle: this.solitaire.cycle,
					goodsId: this.solitaire.goodsId,
					goodsName: this.solitaire.goodsName,
					goodsNo: this.solitaire.goodsNo,
					mainDocunid: this.solitaire.id,
					orderId: this.solitaire.orderId,
					partnerAvatarUrl: this.solitaire.partnerAvatarUrl,
					partnerId: this.solitaire.partnerId,
					partnerName: this.solitaire.partnerName,
					payAmount: this.solitaire.payAmount,
					sceneAssetsId: this.solitaire.sceneAssetsId,
					sceneId: this.solitaire.sceneId,
					supplier: JSON.stringify(this.selectedSupplier),
					supplierId: this.selectedSupplier.userId,
					supplierName: this.selectedSupplier.nickName,
					unitPrice: this.solitaire.unitPrice,
					specification: this.solitaire.specification,
					orderRemarks: this.orderRemarks,
					entity: this.entity,
					couponId: this.selectedCouponObj.id?this.selectedCouponObj.id:'',
					couponAmount: this.selectedCouponObj.couponAmount?this.selectedCouponObj.couponAmount:'',
					originalPayAmount: this.temp_UnitPrice?this.temp_UnitPrice:'',
					useDeduction: this.useDeduction,// 是否使用抵扣
					deductionAmount: this.deductionAmount,// 抵扣金额
				};
				let type = 2;// 拼团购买
				if(this.buyType == 1){
					type = 3;// 直接够买
				}
				let orderExtJson = {
					type: type,
					data: businessData,
					remainAmount: this.remainAmount,
					walletTotalAmount: this.walletTotalAmount
				}
				
				obj.orderExtJson = JSON.stringify(orderExtJson);

				// 1.调用微信支付接口鉴权，返回鉴权信息
				let authinfo = await this.geAuthInfo(obj);
				console.info("支付接口1.authinfo=", authinfo);
				if (authinfo.code != 200) {
					console.log("鉴权失败：" + authinfo);
					this.showMSG('error', '支付失败！');
					this.isClick = false; // 设置按钮为可点击
					return;
				}

				// 2.调用 小程序支付统一接口，这里是以url判断是哪个接口的
				let url = "/api/unifiedorder";
				let respJson = await this.postWxpayServer(url, obj, authinfo);
				console.info("支付接口2.respJson=", respJson);
				if (respJson.code != 200) {
					console.log("调用小程序支付统一接口失败：" + respJson.msg);
					this.showMSG('error', '支付失败！');
					this.isClick = false; // 设置按钮为可点击
					return;
				}

				// 3.开始发起支付动作
				let paymentdata = respJson.data;
				console.log("支付接口3.paymentdata=", paymentdata);
				// hasNext：true表示要发起微信支付，false表示已支付成功
				if (!paymentdata.hasNext) {
					// 0元支付成功（表示写支付记录成功，并未真的进行支付）
					console.log("0元支付成功");
					/**
					 * 延时查询业务是否处理成功；
					 * 1.处理成功，则跳转到订单详情
					 * 2.处理未成功，则提交流程(再次进行业务处理)
					 */
					setTimeout(() => {
						// 根据订单id判断后端是否已经处理好业务
						this.getJoinRecordDetails(this.solitaire.orderId);
					}, 1500);
					return;
				}

				// 开始发起支付动作，进入到这里表示 hasNext = true，需要调用发起微信支付*/
				let that = this;
				let payTag = '';// 记录是否支付成功。0:未支付成功；1:支付成功
				wx.requestPayment({
					...paymentdata,
					success(res) {
						// 此处只能返回通信成功，返回的并不是支付成功，只能在complete中进行业务处理
						console.log("支付成功", res);
						payTag = '1';// 支付成功
					},
					fail(err) {
						console.log("支付失败", err);
						// that.showMSG('error', '支付失败！');
						that.showItem = false; // 关闭 选择支付的方式
						that.isClick = false; // 设置按钮为可点击
						payTag = '0';// 支付失败
					},
					complete(res) {
						/**
						 * 延时查询业务是否处理成功
						 * 1.业务处理成功，则弹出分享海报
						 * 2.业务处理未成功，则再执行一次业务处理
						 */
						if(payTag == '1'){// 支付成功才会执行
							setTimeout(() => {
								// 根据订单id判断后端是否已经处理好业务
								that.getJoinRecordDetails(that.solitaire.orderId);
							}, 1500);
						}
					}
				});
			},

			/**
			 * 根据订单id判断后端是否已经处理好业务
			 */
			async getJoinRecordDetails(orderId){

				let result = await this.$u.api.unifyMiniRestGet({
					systemid: "meily",
					url: "/buying/info/byOrderId/" + orderId,
					loading: true // 默认发起请求会有一个全局的Loading，设置false可去掉
				});
				if (result.code == 200) {
					if(result.data){
						// 1.处理成功，则弹出公众号弹窗
						this.joinRecord = result.data;

						// 计算消费者总分享报酬
						if(this.isNotNull(this.joinRecord.buyQuantity) && this.isNotNull(this.solitaire.consumerShareReward)){
							this.totalShareReward = (Number(this.joinRecord.buyQuantity) * parseFloat(this.solitaire.consumerShareReward)) .toFixed(2);
							this.totalShareRewardPrefix = this.totalShareReward.split(".")[0]
							this.totalShareRewardSuffix = this.totalShareReward.split(".")[1]
						}
						this.success_show = true
						this.showItem = false
					} else {
						// 2.处理未成功，则提交流程(再次进行业务处理)，不在小程序处理业务了
						// this.saveJoinAndOrder();
						this.showItem = false; // 关闭 选择支付的方式
						this.isClick = false; // 设置按钮为可点击
						this.showMSG('error', '出错啦！');
					}
				} else {
					this.$u.toast(result.msg)
				}
			},

			/**
			 * 保存参与记录(包含保存订单记录)
			 */
			async saveJoinAndOrder() {

				// 拼团购买接口地址
				let meilyUrl = "/buying/join";
				if(this.buyType == 1){
					// 直接够买接口地址
					meilyUrl = "/buying/directPurchase"
				}

				const userInfo = uni.getStorageSync('userInfo')
				let result = await this.$u.api.unifyMiniRest({
					systemid: "meily",
					url: meilyUrl,
					address: JSON.stringify(this.addressObj),
					buyQuantity: this.solitaire.buyQuantity,
					cycle: this.solitaire.cycle,
					goodsId: this.solitaire.goodsId,
					goodsName: this.solitaire.goodsName,
					goodsNo: this.solitaire.goodsNo,
					mainDocunid: this.solitaire.id,
					orderId: this.solitaire.orderId,
					partnerAvatarUrl: this.solitaire.partnerAvatarUrl,
					partnerId: this.solitaire.partnerId,
					partnerName: this.solitaire.partnerName,
					payAmount: this.solitaire.payAmount,
					sceneAssetsId: this.solitaire.sceneAssetsId,
					sceneId: this.solitaire.sceneId,
					supplier: JSON.stringify(this.selectedSupplier),
					supplierId: this.selectedSupplier.userId,
					supplierName: this.selectedSupplier.nickName,
					unitPrice: this.solitaire.unitPrice,
					specification: this.solitaire.specification,
					orderRemarks: this.orderRemarks,
					entity: this.entity,
					couponId: this.selectedCouponObj.id?this.selectedCouponObj.id:'',
					couponAmount: this.selectedCouponObj.couponAmount?this.selectedCouponObj.couponAmount:'',
					originalPayAmount: this.temp_UnitPrice?this.temp_UnitPrice:'',
					useDeduction: this.useDeduction,// 是否使用抵扣
					deductionAmount: this.deductionAmount,// 抵扣金额
					loading: true // 默认发起请求会有一个全局的Loading，设置false可去掉
				});
				if (result.code == '200') {
					// 参与拼团记录
					this.joinRecord = result.data;

					// 计算消费者总分享报酬
					if(this.isNotNull(this.joinRecord.buyQuantity) && this.isNotNull(this.solitaire.consumerShareReward)){
						this.totalShareReward = (Number(this.joinRecord.buyQuantity) * parseFloat(this.solitaire.consumerShareReward)) .toFixed(2);
						this.totalShareRewardPrefix = this.totalShareReward.split(".")[0]
						this.totalShareRewardSuffix = this.totalShareReward.split(".")[1]
					}
					this.success_show = true
					this.showItem = false
				} else {
					// 设置按钮为可点击
					this.isClick = false;
					this.showMSG("error", result.msg);
				}
			},

			/**
			 * 购买成功后，点击确定跳转到拼团详情
			 */
			async confirmReload() {
				uni.reLaunch({
					url: '/pages_private_scene2/GroupPurchase/SolitaireDetails?docUnid=' + this.solitaire.id
				})
			},

			/**
			 * 选择收货地址
			 */
			toSelectAddress() {
				this.$u.route('/pages_tabbar_contact/personal_contact/AddressList?type=select');
			},

			/**
			 * 选择支付的方式
			 */
			async clickPopup(item) {
				if (item.action == 'fullPayment' || item.action == 'payALittle') {
					this.doWxPay(item.action);
				} else if (item.action == 'closePopup') {
					this.showItem = false;
				}
			},

			/**
			 * 关闭 选择支付的方式
			 */
			closePopup() {
				this.showItem = false;
			},

			// 选中任一radio时，由radio-group触发
			radioGroupChange(e) {
				for (let i in this.supplierList) {
					if (this.supplierList[i].id == e) {
						this.selectedSupplierId = e;
						this.selectedSupplier = this.supplierList[i]
					}
				}
			},

			/**
			 * 格式化订单名字（名字超长处理）
			 * name：需要处理的字段
			 * MaxLength：要保留的最大长度，包含...
			 */
			formatSubject(name, MaxLength) {
				let cutName = "";
				if (name.length > MaxLength) {
					// 超出的长度，需要截取
					let cutLength = name.length - (name.length - MaxLength) - 3; // 3表示三个省略号的长度
					cutName = name.substring(0, cutLength) + "...";
				} else {
					cutName = name;
				}
				return cutName;
			},

			/**
			 * 关注公众号
			 */
			followOfficialAccount() {
				this.routeAD(this.officialAccountUrl,'outside')
			},

			/**
			 * 关闭公众号弹窗
			 */
			closeOfficialAccount() {
				this.official_account_show = false
				this.success_show = true
			},

			/**
			 * 关闭弹窗跳转到订单详情
			 */
			closeSuccessModal() {
				this.success_show = false
				//“服务商”通过自己的团下单则在订单详情页自定义返回
				if(uni.getStorageSync('userInfo').userId == this.solitaire.initiatorId){
					uni.reLaunch({url: '/pages_private_scene2/GroupPurchase/OrderDetails?recordId=' + this.joinRecord.id+'&showBtn=true&comeback=1'});
				}else{
					uni.reLaunch({url: '/pages_private_scene2/GroupPurchase/OrderDetails?recordId=' + this.joinRecord.id+'&showBtn=true'});
				}
			},

			/**
			 * 生成生成海报
			 */
			async createPoster(docUnid,url,route,type,taskTimes,posterData){
				// 根据订单id查询订单记录中是否已经存了海报地址
				let result = await this.$u.api.unifyMiniRest({
					systemid: "meily",
					url: "/buying/getharePictureUrl",
					shareValidationId: this.joinRecord.shareValidationId,
					loading: false
				});
				if(result.code == 200){
					this.PosterURL = result.data
					if(!this.isNotNull(this.PosterURL)){
						//将分享记录存入分享表中
						let res = await this.$u.api.unifyRequest({
							appid: 'AppletInterface',
							wf_num: 'R_AppletInterface_BD01',
							path: route,//类型
							loading: true, //默认发起请求会有一个全局的Loading，设置false可去掉
						});
						if(res.code == "200"){
							this.QRID = this.guid()
							const userInfo = uni.getStorageSync('userInfo')
							let result = await this.$u.api.unifyRequest({
								appid: 'ACTIVITY',
								wf_num: 'R_ACTIVITY_BY002',
								url: url,//转向地址
								docUnid: docUnid,
								type: res.type,//类型
								completedTimes: 0,//已完成分享次数
								taskTimes: taskTimes?taskTimes:'',//分享任务数
								rulesImplemented: 0,//是否已经执行完成规则
								naturalKey: this.joinRecord.shareValidationId,//业务主键id
								loading: true, //默认发起请求会有一个全局的Loading，设置false可去掉
							});
							if(result.code == "200"){
								this.createCustomPoster(result.scene,docUnid,posterData)
							}else{
								this.showMSG('error',result.msg)
							}
						}
					}else{
						//如果已经存在，直接弹出海报
						this.poster_modal_show = true
					}
				}else{
					this.showMSG('error','出错啦')
				}
			},

			/**
			 * 创建海报
			 */
			async createCustomPoster(scene,docUnid,posterData){
				this.showLoading()
				const userInfo = uni.getStorageSync('userInfo')
				let result = await this.$u.api.unifyMiniRest({
					systemid: "meily",
					url: "/applets/create/poster",
					userId: userInfo.userId,
					nickName: userInfo.nickName,
					avatarUrl: userInfo.avatarUrl,
					imageUrl: posterData.imageURL,
					productName: posterData.productName,
					productPrice: posterData.productPrice,
					pageUrl: 'pages_tabbar_contact/common_contact/guide',
					paramArgs: scene,
					inviteMsg: posterData.invitemsg,
					type: posterData.type,
					giudeText: posterData.giudeText?posterData.giudeText:'',
					priceDesc: posterData.priceDesc?posterData.priceDesc:'',
					loading: true // 默认发起请求会有一个全局的Loading，设置false可去掉
				});
				if(result.code == 200){
					this.PosterURL = result.data
					this.hideLoading()
					if(this.isNotNull(this.PosterURL)){
						//调用接口将海报地址存入订单数据中
						this.addPosterToOrder()
					}else{
						this.showMSG('error','出错啦')
					}
				}else{
					this.showMSG('error','出错啦')
				}
			},

			/**
			 * 调用接口将海报地址存入订单数据中
			 */
			async addPosterToOrder(){
				let result = await this.$u.api.unifyMiniRest({
					systemid: "meily",
					url: "/buying/saveSharePictureUrl",
					shareValidationId: this.joinRecord.shareValidationId,
					sharePictureUrl: this.PosterURL,
					loading: false
				});
				if(result.code == 200){
					this.poster_modal_show = true
				}else{
					this.showMSG('error','出错啦')
				}
			},

			// toast生成中
			showLoading() {
				wx.showLoading({
				  title: '正在生成中...',
				  icon: 'none',
				});
			},

			hideLoading() {
				wx.hideLoading();
			},

			// 长按保存图片
			saveImg(url){
			  //用户需要授权
			  wx.getSetting({
				success: (res) => {
					if (!res.authSetting['scope.writePhotosAlbum']) {
					 wx.authorize({
					  scope: 'scope.writePhotosAlbum',
					  success:()=> {
					   // 同意授权
					   this.saveImg1(url);
					  },
					  fail: (res) =>{
					   console.log(res);
					  }
					 })
					}else{
					 // 已经授权了
					 this.saveImg1(url);
					}
				   },
				   fail: (res) =>{
					console.log(res);
				   }
				})
			},

			/**
			 * 保存到相册
			 */
			SaveAlbum(url) {
				wx.getImageInfo({
				   src: url,
				   success:(res)=> {
					let path = res.path;
					wx.saveImageToPhotosAlbum({
					 filePath:path,
					 success:(res)=> {
					    this.showMSG("success","保存成功！")
					 },
					 fail:(res)=>{
					  console.log("----SaveAlbum fail---")
					  console.log(res);
						this.$u.toast("请点击右上角进入设置并开启添加到相册的权限才能保存到相册噢！")
					 }
					})
				   },
				   fail:(res)=> {
					console.log(res);
				   }
				})
			},

			/**
			 * 复制链接
			 */
			copyLink (link) {
				wx.setClipboardData({
				  //准备复制的数据内容
				  data: link,
				  success: function (res) {
					wx.showToast({
					  title: '已复制',
					});
				  }
				});
			},

			/**
			 * 获取商品详情
			 */
			async getGoodsDetails(goodsId, goodsNo, cycle) {
				let result = await this.$u.api.unifyMiniRestGet({
					systemid: "meily",
					url: "/goods/get/" + goodsNo + "/" + goodsId,
				});
				if (result.code == 200) {
					this.goodsType = result.data.goodsType
					this.foremanReward = result.data.foremanReward;
					this.shareData.posterData.productPrice = result.data.discountPrice;

					let purchaseQuota = result.data.purchaseQuota;// 用户限购数量
					if(this.isNotNull(purchaseQuota) && Number(purchaseQuota) > 0){
						// 用户限购不为空，则需要判断当前周期当前商品当前用户购买了几件商品，商品是否限购，还能购买几件

						// 获取当前周期当前商品购买的商品总数
						let result2 = await this.$u.api.unifyMiniRest({
							systemid: "meily",
							url: "/buying/getQuantityByCurrentCycle",
							partnerId: this.solitaire.partnerId,
							goodsId: goodsId,
							goodsNo: goodsNo,
							cycle: cycle,
							loading: true // 默认发起请求会有一个全局的Loading，设置false可去掉
						});
						if (result2.code == 200) {
							let totalPurchased = result2.data;// 已购买总数
							if(Number(totalPurchased) < Number(purchaseQuota)){
								// 如果已购买数量 小于 限购数量，计算还能购买的数量
								this.buyQuantityMax = Number(purchaseQuota) - Number(totalPurchased);
							} else {
								setTimeout(() => {
									// 否则，提示无法购买，2秒后返回上一页
									this.$u.toast("已达每人限购数量，无法购买！");
									this.isClick = true;// 设置按钮为不可点击
								}, 1000);
								setTimeout(() => {
									this.goBack()
								}, 2000);
							}
						}
					}
				}
			},

			/**
			 * 跳转到销售机会页面
			 */
			async toGoodsDetails(){
				this.$u.route('/pages_private_scene2/GroupPurchase/DistributionGoods?goodsNo=' + this.solitaire.goodsNo + '&goodsId=' + this.solitaire.goodsId);
			},

		}
	}
</script>

<style scoped>
	aui-flexView {
		width: 100%;
		height: 100%;
		margin: 0 auto;
		display: -webkit-box;
		display: -webkit-flex;
		display: -ms-flexbox;
		display: flex;
		-webkit-box-orient: vertical;
		-webkit-box-direction: normal;
		-webkit-flex-direction: column;
		-ms-flex-direction: column;
		flex-direction: column;
	}

	.aui-scrollView {
		width: 100%;
		height: 100%;
		-webkit-box-flex: 1;
		-webkit-flex: 1;
		-ms-flex: 1;
		flex: 1;
		overflow-y: auto;
		overflow-x: hidden;
		-webkit-overflow-scrolling: touch;
		position: relative;
		margin-top: 0;
	}

	.aui-navBar {
		height: 44px;
		position: relative;
		display: -webkit-box;
		display: -webkit-flex;
		display: -ms-flexbox;
		display: flex;
		z-index: 1002;
		background: #f7f7f7;
	}

	.b-line {
		position: relative;
	}

	.b-line:after {
		content: '';
		position: absolute;
		z-index: 2;
		bottom: 0;
		left: 0;
		width: 100%;
		height: 1px;
		border-bottom: 1px solid #e2e2e2;
		-webkit-transform: scaleY(0.5);
		transform: scaleY(0.5);
		-webkit-transform-origin: 0 100%;
		transform-origin: 0 100%;
	}

	.aui-navBar-item {
		height: 44px;
		min-width: 25%;
		-webkit-box-flex: 0;
		-webkit-flex: 0 0 25%;
		-ms-flex: 0 0 25%;
		flex: 0 0 25%;
		padding: 0 0.9rem;
		display: -webkit-box;
		display: -webkit-flex;
		display: -ms-flexbox;
		display: flex;
		-webkit-box-align: center;
		-webkit-align-items: center;
		-ms-flex-align: center;
		align-items: center;
		font-size: 0.7rem;
		white-space: nowrap;
		overflow: hidden;
		color: #353535;
		position: relative;
	}

	.aui-navBar-item:first-child {
		-webkit-box-ordinal-group: 2;
		-webkit-order: 1;
		-ms-flex-order: 1;
		order: 1;
		margin-right: -25%;
		font-size: 0.9rem;
		font-weight: bold;
	}

	.aui-navBar-item:last-child {
		-webkit-box-ordinal-group: 4;
		-webkit-order: 3;
		-ms-flex-order: 3;
		order: 3;
		-webkit-box-pack: end;
		-webkit-justify-content: flex-end;
		-ms-flex-pack: end;
		justify-content: flex-end;
	}

	.aui-center {
		-webkit-box-ordinal-group: 3;
		-webkit-order: 2;
		-ms-flex-order: 2;
		order: 2;
		display: -webkit-box;
		display: -webkit-flex;
		display: -ms-flexbox;
		display: flex;
		-webkit-box-pack: center;
		-webkit-justify-content: center;
		-ms-flex-pack: center;
		justify-content: center;
		-webkit-box-align: center;
		-webkit-align-items: center;
		-ms-flex-align: center;
		align-items: center;
		height: 44px;
		width: 50%;
		margin-left: 25%;
	}

	.aui-center-title {
		text-align: center;
		width: 100%;
		white-space: nowrap;
		overflow: hidden;
		display: block;
		text-overflow: ellipsis;
		font-size: 0.95rem;
		color: #333;
	}

	.icon {
		width: 20px;
		height: 20px;
		display: block;
		border: none;
		float: left;
		background-size: 20px;
		background-repeat: no-repeat;
	}

	.aui-flex {
		display: -webkit-box;
		display: -webkit-flex;
		display: flex;
		-webkit-box-align: center;
		-webkit-align-items: center;
		align-items: center;
		padding: 30rpx;
		position: relative;
	}

	.aui-flex-box {
		-webkit-box-flex: 1;
		-webkit-flex: 1;
		flex: 1;
		min-width: 0;
		font-size: 14px;
		color: #333;
	}

	.aui-flex-triangle {
		position: relative;
		font-size: 14px;
		padding-right: 15px;
	}

	.aui-flex-triangle:before {
		content: '';
		width: 0;
		height: 0;
		border-width: 5px 0px 5px 8px;
		border-style: solid;
		border-color: transparent transparent transparent #7b7b7b;
		position: absolute;
		top: 6px;
		right: 0;
		border-radius: 1;
	}

	.aui-choice-white {
		background: #fff;
	}

	.aui-order-box {
		padding: 10px 20px;
	}

	.aui-flex-goods {
		margin-right: .8em;
		width: 160rpx;
		height: 160rpx;
		line-height: 160rpx;
		text-align: center;
	}

	.aui-flex-goods img {
		width: 100%;
		max-height: 100%;
		vertical-align: top;
	}

	.aui-flex-default {
		/* background: #f3f1f1; */
	}

	.aui-flex-default h2 {
		font-size: 14px;
		width: auto;
		overflow: hidden;
		text-overflow: ellipsis;
		white-space: nowrap;
		word-wrap: normal;
		word-wrap: break-word;
		word-break: break-all;
		padding-bottom: 5px;
	}

	.aui-flex-default p {
		color: #999999;
		font-size: 12px;
	}

	.aui-flex-clear {
		padding: 0;
		/* margin-top: 20px; */
	}

	.aui-flex-clear .aui-flex-box {
		color: #f21956;
		font-weight: bold;
	}

	.aui-mar15 {
		margin-bottom: 15px;
	}

	.aui-flex-triangle-clear:before {
		border-color: #fff;
	}

	.aui-flex-box h2 {
		font-size: 16px;
		padding-bottom: 5px;
	}

	.aui-flex-box h3 {
		font-size: 14px;
		padding-bottom: 5px;
	}

	.aui-flex-box p {
		font-size: 12px;
		color: #999;
		line-height: 1.2;
		overflow: hidden;
		text-overflow: ellipsis;
		display: -webkit-box;
		-webkit-box-orient: vertical;
		-webkit-line-clamp: 1;
	}

	.aui-bar-footer {
		/* line-height: 200rpx;
		height: 200rpx; */
		background: #fff;
		box-shadow: 0 -4rpx 20rpx #ddd;
		position: fixed;
		z-index: 999;
		bottom: 0;
		left: 0;
		width: 100%;
	}

	.aui-btn-button {
		background: #f21956;
		padding: 0 25px;
		color: #fff;
		font-size: 14px;
	}

	.aui-bar-footer .aui-flex {
		padding: 0;
	}

	.aui-bar-footer .aui-flex-box {
		padding-left: 15px;
	}

	.aui-bar-footer .aui-flex-box span {
		font-style: normal;
		color: #eb5468;
	}

	.cnt {
		padding-top: 1px;
		color: #e61111;
		position: relative;
		line-height: 22px;
		font-size: 14px;
		font-weight: 500;
	}

	.popup-box {
		padding-bottom: 50rpx;
		padding-top: 50rpx;
	}

	.popup-item {
		height: 100rpx;
		line-height: 100rpx;
		text-align: center;
		font-size: 33rpx;
	}

	.aui-tag {
		display: inline
	}

	.cont-right {
		display: flex;
		flex-direction: column;
	}

	.cont-right p {
		width: 100%;
	}

	.xmname {
		opacity: 0.7;
		font-family: PingFangSC-Regular;
		font-size: 14px;
		color: #3B353C;
		line-height: 22px;
	}

	.name {
		font-family: PingFangSC-Regular;
		font-size: 14px;
		color: #3B353C;
		letter-spacing: 0;
		line-height: 22px;
	}

	.solitaire-title {
		display: -webkit-box;
		/*必须结合的属性,将对象作为弹性伸缩盒子模型显示*/
		-webkit-line-clamp: 1;
		/*设置多少行*/
		-webkit-box-orient: vertical;
		/*必须结合的属性,设置或检索伸缩盒对象的子元素的排列方式*/
		overflow: hidden;
		/*文本会被修剪，并且剩余的部分不可见*/
		text-overflow: ellipsis;
		/*显示省略号来代表被修剪的文本*/
		font-size: 28rpx;
	}

	.color-red {
		color: red;
	}

	.font-weight-550 {
		font-weight: 550;
	}

	.success-modal-bottom {
		background: url(https://www-1308272144.cos.ap-guangzhou.myqcloud.com/Meily/icon/Share/ShareTips.png) no-repeat;
		background-size: 100%;
		height: 60rpx;
	}

	.success-modal-share {
		display: flex;
		justify-content: center;
		padding-top: 310rpx;
	}

	.success-modal-content {
		background: url(https://www-1308272144.cos.ap-guangzhou.myqcloud.com/Meily/GroupPurchase/consumerSharePop.png) no-repeat;
		background-size: 100% 100%;
		height: 750rpx;
		width: 600rpx;
	}

	.buy-goods-share {
		font-size: 30rpx;
		width: 300rpx;
		height: 100rpx;
		padding: 0;
		background: url(https://www-1308272144.cos.ap-guangzhou.myqcloud.com/Meily/GroupPurchase/consumerSharePopBtn.png) repeat;
		background-size: cover;
		border: none !important;
		padding-left: 0rpx !important;
		padding-right: 0rpx !important;
		padding-top: 6rpx !important;
	}

	.mask-solt {
		display: flex;
		justify-content: center;
		align-items: center;
		height: 100%;
	}

	.mask-close {
		display: flex;
		justify-content: center;
	}

	.official-account-bg {
		background: url(https://www-1308272144.cos.ap-guangzhou.myqcloud.com/Meily/icon/Share/ShareofficialAccount.png) no-repeat;background-size: 100% 100%;
		width: 540rpx;
		height: 780rpx;
	}

	.default-tag {
		padding: 0rpx 5rpx;
		background-color: #e5392b;
		color: #ffffff;
		border-radius: 5rpx;
		font-size: 20rpx;
		margin-right: 10rpx;
	}

	.aui-flex2 {
		display: -webkit-box;
		display: -webkit-flex;
		display: flex;
		-webkit-box-align: center;
		-webkit-align-items: center;
		align-items: center;
		padding: 20rpx 30rpx;
		position: relative;
	}

	.border-radius-30 {
		border-radius: 30rpx;
	}

	.address1 {
		width: 560rpx;
		overflow:hidden;
		text-overflow:ellipsis;
		display:-webkit-box;
		-webkit-box-orient:vertical;
		-webkit-line-clamp:1;
	}

	.u-fz-60 {
		font-size: 120rpx;
	}

	.notice-bar {
		background-color: #f7591f;
		color: #ffffff;
		text-align: center;
		height: 80rpx;
		line-height: 80rpx;
		font-size: 24rpx;
		/* position: fixed;
		top: 1;
		left: 0;
		right: 0;
		z-index: 3; */
		width: 100%;
	}

</style>
